<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="centre/manage/include :: header">
</head>
<link rel="stylesheet" type="text/css" href="/css/plugins/layui/layui.css"/>
<style>
input[type=email], input[type=url], input[type=search], input[type=tel],
	input[type=color], input[type=text], input[type=password], input[type=datetime],
	input[type=datetime-local], input[type=date], input[type=month], input[type=time],
	input[type=week], input[type=number], textarea {
	border-radius: 0 !important;
	color: #858585;
	background-color: #FFF;
	border: 1px solid #D5D5D5;
	padding: 5px 4px 6px;
	font-size: 14px;
	font-family: inherit;
	-webkit-box-shadow: none !important;
	box-shadow: none !important;
	-webkit-transition-duration: .1s;
	transition-duration: .1s;
}
select {
    padding: 3px 4px;
    height: 30px;
}
.table{
	margin-bottom: 0px;
	table-layout: fixed;
}
</style>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">
			<div class="panel panel-info">
				<div class="panel-heading">门店退货统计</div>
			    <div class="panel-body">
			        <div class="form-horizontal">
		             <div class="form-group" style="padding-left:60px;">
		              <div class="col-xs-12 col-sm-4 hidden-xs btn-sespan" >
						<div class="input-group">
							<span class="input-group-addon" style="height:30px;">
								申请时间
							</span>
							<input type="text" name="payStartTime" id="payStartTime" 
								value="" placeholder="点击选择开始时间" 
								readonly class="layui-input form-control"
								style="height:30px;"/>
							<span>
								<i class="fa fa-exchange"></i>
							</span>
							<input type="text"  name="payEndTime" id="payEndTime" 
								value="" placeholder="点击选择结束时间" 
								readonly class="layui-input form-control"
								style="height:30px;"/>
	 					
						</div>
					 </div>
					 <div class="col-xs-12 col-sm-2 hidden-xs btn-sespan" data-toggle="distpicker" id="dist_target">
	                    <select class="form-control tpl-category-parent" id="province" name="province" data-province="----选择省----">
						</select>
						<select class="form-control tpl-category-child"  id="city" name="city" data-city="----选择市----">
						</select>
		             </div>
		             <!-- <div class="pull-right search col-md-3 nopadding" data-toggle="distpicker" id="dist_target">
							<div class="form-control tpl-category-parent" style="padding-right: 0px">
								<select class="form-control chosen-select" id="province" name="province" data-province="----选择省----"></select>
							</div>
							<div class="col-sm-6" style="padding-left: 0px">
								<select class="form-control chosen-select"  id="city" name="city"  data-city="----选择市----"></select>
							</div>
						</div> -->
					 <div class="col-xs-12 col-sm-2 hidden-xs btn-sespan" >
                   		<select class="form-control" id="payState"
							name="payState">
							<option value="">退款状态</option>
							<option value="1">已审核</option>
							<option value="2">已退款</option>
							<option value="0">待审核</option>
						</select>
		             </div>
		             <div class="col-xs-12 col-sm-2 hidden-xs btn-sespan">
	                    <select class="form-control" id="column">
							<option value="">排序方式</option>
							<option value="count">按退款额</option>
							<option value="sumPrice">排退款量</option>
						</select>
		             </div>
		             <input type="hidden" id="centreId" name="centreId" th:value="${centreId}" th:if="${flag} == '1'">
					 <div class="col-xs-12 col-sm-2 hidden-xs btn-sespan" th:if="${flag} == '0'">
						<select data-placeholder="商户" class="form-control chosen-select" id="centreId" name="centreId" tabindex="2">
							<option value="">选择商户</option>
							<option th:each="item: ${centreList}" th:text="${item.name}" th:value="${item.centreId}"></option>
						</select>
					 </div>
		            </div>
		            
		            <div class="form-group" style="padding-left:60px;">
		            	<div class="col-xs-12 col-sm-4 hidden-xs btn-sespan" >
							<input class="form-control" id="tzOrXqName" name="tzOrXqName" 
								placeholder="输入需查询的门店或门店名称" type="text" value="">
		             	</div>
		                <div class="col-sm-6 col-lg-9 col-xs-12">
		                    <button class="btn btn-default" onclick="reLoad()">
		                    	<i class="fa fa-search"></i> 搜索
		                    </button>
		                    <button id="modal_userid" onclick="exportExcel()"
		                    	class="btn btn-default" 
		                    	style='margin-left:10px;'>
								<span class="fa fa-download"></span>
								导出Excel
							</button>
		                </div>
		            </div>
			        </div>
			    </div>
			</div>
			
			<div class="panel panel-default">
    			<div class="panel-body" style="padding: 0;">
    				<table id="memberRefundTable" data-mobile-responsive="true">
					</table>
    			</div>
			</div>
		</div>
			
		</div>
		</div>
	<div th:include="centre/manage/include::footer"></div>
	<script src="/js/plugins/distpicker/distpicker.data.min.js" ></script>
	<script src="/js/plugins/distpicker/distpicker.min.js" ></script>
	<script type="text/javascript" src="/public/ace/js/ace-extra.js"></script>
	<script type="text/javascript" src="/js/plugins/layui/layui.js"></script>
	<script type="text/javascript">
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}

		var prefix = "/report/manage";
		$(document).ready(function () {
			$("#province").val("");
			$("#city").val("");
		    load();
		});
		function load() {
			$('#memberRefundTable').bootstrapTable({
				method : 'get', // 服务器数据的请求方式 get or post
				url : prefix + "/memberRefund", // 服务器数据的加载地址
				showRefresh : true,
				// showToggle : true,
				iconSize : 'outline',
				// toolbar: '#exampleToolbar',
				striped : true, // 设置为true会有隔行变色效果
				dataType : "json", // 服务器返回的数据类型
				//pagination : true, // 设置为true会在底部显示分页条
				pageList : [ 10, 20, 50 ],
				//queryParamsType : "limit",
				// //设置为limit则会发送符合RESTFull格式的参数
				singleSelect : false, // 设置为true将禁止多选
				// contentType : "application/x-www-form-urlencoded",
				// //发送到服务器的数据编码类型
				pageSize : 10, // 如果设置了分页，每页数据条数
				pageNumber : 1, // 如果设置了分布，首页页码
				// search : true, // 是否显示搜索框
				showColumns : true, // 是否显示内容下拉框（选择显示的列）
				showFooter : true,
				sidePagination : "server", // 设置在哪里进行分页，可选值为"client" 或者
				// "server"
				queryParams : function(params) {
					return {
                        limit : 1,
                        offset : 1 ,
						payStartTime: $.trim($("#payStartTime").val()),
						payEndTime: $.trim($("#payEndTime").val()),
						province: $.trim($("#province").val()),
						city: $.trim($("#city").val()),
						status: $.trim($("#payState").val()),
						column: $.trim($("#column").val()),
						centreId:$.trim($("#centreId").val()),
						tzOrXqName:$.trim($("#tzOrXqName").val())
					};
				},
				columns: [
				{
				    title: '门店姓名',
				    field: 'realname',
				    footerFormatter : function(value, index) {
                    	return "总计" + $('#memberRefundTable').bootstrapTable('getOptions').totalRows + "个门店";
                    }
				},{
                    title: '门店名称',
                    field: 'tXiaoquName'
                },{
                    title: '退单数量',
                    field: 'count',
				    footerFormatter : function(value) {
				    	var count = 0;
				    	for (var i=0;i<value.length;i++){
				    		count += value[i].count*10;
				    	}
                    	return "退货总量:" + count/10;
                    }
                },{
                    title: '所占比例',
                    field: 'countRate',
                    formatter: function (value, row, index) {
                    	return '<div class="progress">' +
                    	         '<div class="progress-bar" role="progressbar" aria-valuenow="60"  aria-valuemin="0" aria-valuemax="100" style="width: ' + value + '%;">' +
                                    '<span><font color="#000000">' + value + '%</font></span>' + 
                                 '</div>' + 
                               '</div>';
                    }
                },{
                    title: '退款金额',
                    field: 'sumPrice',
				    footerFormatter : function(value) {
				    	var count = 0;
				    	for (var i=0;i<value.length;i++){
				    		count += value[i].sumPrice*100;
				    	}
                    	return "退单金额:￥" + count/100;
                    }
                },{
                    title: '所占比例',
                    field: 'priceRate',
                    formatter: function (value, row, index) {
                    	return '<div class="progress">' +
                    	         '<div class="progress-bar" role="progressbar" aria-valuenow="60"  aria-valuemin="0" aria-valuemax="100" style="width: ' + value + '%;">' +
                                    '<span><font color="#000000">' + value + '%</font></span>' + 
                                 '</div>' + 
                               '</div>';
                    }
                }]
			});
		}
		function reLoad() {
			$('#memberRefundTable').bootstrapTable('refresh');
		}
		
		function exportExcel() {
			var payStartTime = $.trim($("#payStartTime").val());
			var payEndTime = $.trim($("#payEndTime").val());
			var province = $.trim($("#province").val());
			var city = $.trim($("#city").val());
			var status = $.trim($("#payState").val());
			var column = $.trim($("#column").val());
			var centreId = $.trim($("#centreId").val());
			var tzOrXqName = $.trim($("#tzOrXqName").val());
		    window.location.href = prefix + "/exportMemberRefund?payStartTime=" + payStartTime + 
		    		"&payEndTime=" + payEndTime +"&province=" + province +"&city=" + city +
		    		"&status=" + status +"&column=" + column +"&centreId=" + centreId + 
		    		"&tzOrXqName=" + tzOrXqName;
		}
		
		
	</script>
	
</body>
</html>
